package com.ruoyi.leave.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.leave.mapper.LeaveTeacherRecordMapper;
import com.ruoyi.leave.service.ILeaveTeacherRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.leave.mapper.LeaveRecordMapper;
import com.ruoyi.leave.domain.LeaveRecord;
import com.ruoyi.leave.service.ILeaveRecordService;

/**
 * 请假记录Service业务层处理
 * 
 * @author Weiney
 * @date 2025-03-11
 */
@Service
public class LeaveTeacherRecordServiceImpl implements ILeaveTeacherRecordService
{
    @Autowired
    private LeaveTeacherRecordMapper leaveTeacherRecordMapper;

    /**
     * 查询请假记录
     * 
     * @param leaveId 请假记录主键
     * @return 请假记录
     */
    @Override
    public LeaveRecord selectLeaveTeacherRecordByLeaveId(Long leaveId)
    {
        return leaveTeacherRecordMapper.selectLeaveTeacherRecordByLeaveId(leaveId);
    }

    /**
     * 查询请假记录列表
     * 
     * @param leaveRecord 请假记录
     * @return 请假记录
     */
    @Override
    public List<LeaveRecord> selectLeaveTeacherRecordList(LeaveRecord leaveRecord)
    {
        return leaveTeacherRecordMapper.selectLeaveTeacherRecordList(leaveRecord);
    }

    /**
     * 新增请假记录
     * 
     * @param leaveRecord 请假记录
     * @return 结果
     */
    @Override
    public int insertLeaveTeacherRecord(LeaveRecord leaveRecord)
    {

        return leaveTeacherRecordMapper.insertLeaveTeacherRecord(leaveRecord);
    }

    /**
     * 修改请假记录
     * 
     * @param leaveRecord 请假记录
     * @return 结果
     */
    @Override
    public int updateLeaveTeacherRecord(LeaveRecord leaveRecord)
    {
        leaveRecord.setApprovalTime(DateUtils.getNowDate());
        leaveRecord.setApprovalStatus(1L); // 已完成
        return leaveTeacherRecordMapper.updateLeaveTeacherRecord(leaveRecord);
    }

    /**
     * 批量删除请假记录
     * 
     * @param leaveIds 需要删除的请假记录主键
     * @return 结果
     */
    @Override
    public int deleteLeaveTeacherRecordByLeaveIds(Long[] leaveIds)
    {
        return leaveTeacherRecordMapper.deleteLeaveTeacherRecordByLeaveIds(leaveIds);
    }

    /**
     * 删除请假记录信息
     * 
     * @param leaveId 请假记录主键
     * @return 结果
     */
    @Override
    public int deleteLeaveTeacherRecordByLeaveId(Long leaveId)
    {
        return leaveTeacherRecordMapper.deleteLeaveTeacherRecordByLeaveId(leaveId);
    }
}
